package org.jash.sportnews2109.ui

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import com.alibaba.android.arouter.facade.annotation.Route
import org.jash.common.mvvm.BaseFragment
import org.jash.common.token
import org.jash.sportnews2109.R
import org.jash.sportnews2109.databinding.FragmentMineBinding
import org.jash.sportnews2109.vm.MineViewModel

@Route(path = "/news/mine")
class MineFragment : BaseFragment<FragmentMineBinding, MineViewModel>() {
    override fun initView() {
        binding.logout.setOnClickListener {
            viewModel.logout()
        }
    }

    override fun initData() {
        viewModel.logoutLiveData.observe(viewLifecycleOwner, this::success)
    }
    fun success(msg:String){
        token = null
        Toast.makeText(requireContext(), msg, Toast.LENGTH_SHORT).show()
        (requireActivity() as MainActivity).binding.navigation.selectedItemId = R.id.home
    }

}